// Ariel White, Claudine Gay, Jennifer Hochschild
// July 2015
// Replication code for ANES 2012 analyses discussed in paper

// Setup
cd "/nfs/home/A/awhite/shared_space/linkedfate/ARW_rep_june2012/ANES/ANES2012" 
clear
set more off
use "anes_timeseries_2012_stata12.dta" //downloaded this from ANES website in January 2014 

svyset [pweight= weight_full]

gen blackracialLF = .
replace blackracialLF = 0 if link_black == 2
replace blackracialLF = 1 if link_blackamt == 3
replace blackracialLF = 2 if link_blackamt == 2
replace blackracialLF = 3 if link_blackamt == 1

gen whiteracialLF = .
replace whiteracialLF = 0 if link_white== 2
replace whiteracialLF = 1 if link_whiteamt == 3
replace whiteracialLF = 2 if link_whiteamt == 2
replace whiteracialLF = 3 if link_whiteamt == 1

gen hispanicracialLF = .
replace hispanicracialLF = 0 if link_hisp== 2
replace hispanicracialLF = 1 if link_hispamt == 3
replace hispanicracialLF = 2 if link_hispamt == 2
replace hispanicracialLF = 3 if link_hispamt == 1


// Are the LF questions correlated?
gen racialLF = .
replace racialLF = 0 if blackracialLF == 0 | hispanicracialLF == 0 | whiteracialLF == 0
replace racialLF = 1 if blackracialLF == 1 | hispanicracialLF == 1 | whiteracialLF == 1 
replace racialLF = 2 if blackracialLF == 2 | hispanicracialLF == 2 | whiteracialLF == 2 
replace racialLF = 3 if blackracialLF == 3 | hispanicracialLF == 3 | whiteracialLF == 3 

gen othersLF = .
replace othersLF = 0 if link_oth == 2
replace othersLF= 1 if link_othamt == 3
replace othersLF = 2 if link_othamt == 2
replace othersLF = 3 if link_othamt == 1

gen womenLF = .
replace womenLF = 0 if link_wom== 2
replace womenLF= 1 if link_womamt == 3
replace womenLF = 2 if link_womamt == 2
replace womenLF = 3 if link_womamt == 1

pwcorr racialLF othersLF
pwcorr racialLF womenLF
pwcorr othersLF womenLF

//What proportion of people reporting racial/gender linked fate also say "others"?
gen othersLFbinary = 0
replace othersLFbinary = 1 if othersLF > 0 
svy:mean othersLFbinary if link_hisp==1
svy:mean othersLFbinary if link_white==1
svy:mean othersLFbinary if link_black ==1
svy:mean othersLFbinary if link_wom ==1

preserve
keep if gender_respondent==2 //women only
svy:mean othersLFbinary if link_hisp==1
svy:mean othersLFbinary if link_white==1
svy:mean othersLFbinary if link_black ==1
restore


// Do group FT ratings predict group LF scores?

//set up feeling thermometers
gen ft_hisp = ftcasi_hisp if ftcasi_hisp >0
gen ft_black = ftcasi_black if ftcasi_black >0
gen ft_white = ftcasi_white if ftcasi_white >0
gen ft_feminist = ftgr_feminists if ftgr_feminists>0

pwcorr ft_hisp hispanicracialLF
pwcorr ft_black blackracialLF
pwcorr ft_white whiteracialLF
pwcorr ft_feminist womenLF
//correlations all below .15 (and note that the highest one is "feminist" feeling thermometer, not quite the same as women.)

svy:reg whiteracialLF ft_white
svy:reg blackracialLF ft_black

// Is LF correlated with a sense of group discrimination/inequality?

gen egal_bigprob_cl = 5- egal_bigprob if egal_bigprob >0
//note that this isn't group-specific.
pwcorr egal_bigprob_cl blackracialLF 
pwcorr egal_bigprob_cl whiteracialLF 
pwcorr egal_bigprob_cl hispanicracialLF 
pwcorr egal_bigprob_cl womenLF 
pwcorr egal_bigprob_cl othersLF 

//do the basic CASI discrimination measures
gen modsex_discamt_cl = modsex_discamt if modsex_discamt >0
pwcorr modsex_discamt_cl womenLF
svy:reg womenLF modsex_discamt_cl

gen discrim_whites_cl = 5-discrim_whites if discrim_whites>0
gen discrim_blacks_cl = 5-discrim_blacks if discrim_blacks>0
gen discrim_hispanics_cl = 5-discrim_hispanics if discrim_hispanics>0
gen discrim_women_cl = 5-discrim_women if discrim_women>0

svy:reg hispanicracialLF discrim_hispanics_cl
svy:reg whiteracialLF discrim_whites_cl
svy:reg hispanicracialLF discrim_hispanics_cl
svy:reg womenLF discrim_women_cl //regression example discussed in paper

gen racialdiscrim = 0 if discrim_whites_cl == 0 | discrim_hispanics_cl == 0 | discrim_blacks_cl == 0
replace racialdiscrim = 1 if discrim_whites_cl == 1 | discrim_hispanics_cl == 1 | discrim_blacks_cl == 1
replace racialdiscrim = 2 if discrim_whites_cl == 2 | discrim_hispanics_cl == 2 | discrim_blacks_cl == 2
replace racialdiscrim = 3 if discrim_whites_cl == 3 | discrim_hispanics_cl == 3 | discrim_blacks_cl == 3
replace racialdiscrim = 4 if discrim_whites_cl == 4 | discrim_hispanics_cl == 4 | discrim_blacks_cl == 4


label var discrim_women_cl "Group Discrimination"
label var discrim_blacks_cl "Group Discrimination"
label var discrim_whites_cl "Group Discrimination"
label var discrim_hispanics_cl "Group Discrimination"

label var ft_feminist "Group Feeling Thermometer"
label var ft_black "Group Feeling Thermometer"
label var ft_white "Group Feeling Thermometer"
label var ft_hisp "Group Feeling Thermometer"

label var othersLF "Linked Fate with 'Others'"

//make Table 2 from the paper:
svy:reg womenLF discrim_women_cl discrim_blacks_cl othersLF ft_feminist
reg womenLF discrim_women_cl othersLF ft_feminist [pweight=weight_full], beta
outreg using ANES_regs.doc, se varlabels replace

svy:reg blackracialLF  discrim_blacks_cl othersLF ft_black
reg blackracialLF  discrim_blacks_cl othersLF ft_black [pweight=weight_full], beta
outreg using ANES_regs.doc, se varlabels merge

svy:reg whiteracialLF  discrim_whites_cl othersLF ft_white
reg whiteracialLF  discrim_whites_cl othersLF ft_white [pweight=weight_full], beta
outreg using ANES_regs.doc, se varlabels merge

svy:reg hispanicracialLF  discrim_hispanics_cl othersLF ft_hisp
reg hispanicracialLF  discrim_hispanics_cl othersLF ft_hisp [pweight=weight_full], beta
outreg using ANES_regs.doc,  se varlabels merge


